#include <string.h>

#include "verbs.h"
#include "verb/probe.h"
#include "verb/pageinfo.h"
#include "verb/encrypt.h"
#include "verb/onlineinfo.h"
#include "verb/login.h"
#include "verb/logout.h"
#include "verb/try-login.h"
#include "verb/try-logout.h"

const Verb ALL_VERBS[] = {
    {"probe", verb_probe},
    {"pageinfo", verb_pageinfo},
    {"encrypt", verb_encrypt},
    {"onlineinfo", verb_onlineinfo},
    {"login", verb_login},
    {"logout", verb_logout},
    {"try-login", verb_try_login},
    {"try-logout", verb_try_logout},
    {0, NULL}
};

const Verb* verbs_find_verb(const char* name, const Verb verbs[]) {
    // TODO add partial matching function
    for (Verb* verb = (Verb*) verbs; verb -> name; verb++) {
        if (strcmp(name, verb -> name) == 0) {
            return verb;
        }
    }
    // No verb matched.
    return NULL;
}
